var currenPage = 1;
var pageSize = 10;

//1.获取token
var token = sessionStorage.getItem("token");
console.log(token);
var baseUrl = 'http://39.106.47.64:7788/';
//1.请求所有用户角色，到下拉列表框里
$.ajax({
    url: baseUrl + "role/findAll",
    type: 'get',
    headers: {
        "Authorization": sessionStorage.getItem("token")
    },
    success: function(data) {
        data.data.forEach((item) => {
            $(".user_container .val").after(`<option>` + item.name + `</option>`);
        });
    }
});

//2.封装请求所有用户数据函数
findAllByPage(currenPage, pageSize, username, rolename)
if (username != '') {
    url = baseUrl + '/baseUser/pageQuery?page=' + currenPage + '&pageSize=' + pageSize + '&username=' + username
} else if (rolename != '请选择角色') {
    url = baseUrl + '/baseUser/pageQuery?page=' + currenPage + '&pageSize=' + pageSize + '&rolename=' + rolename
} else if (username != '' && rolename != '请选择角色') {
    url = baseUrl + '/baseUser/pageQuery?page=' + currenPage + '&pageSize=' + pageSize + '&username=' + username + '&rolename=' + rolename
} else {
    //均为空
    url = baseUrl + '/baseUser/pageQuery?page=' + currenPage + '&pageSize=' + pageSize
}
$.ajax({
    url: url,
    type: 'get',
    headers: {
        "Authorization": sessionStorage.getItem("token")
    },
    success: function(data) {
        //根据分页/搜索框查询出来的所有用户数据
        console.log(data, '根据分页/搜索框查询出来的所有用户数据');
    }
});;

// findAllByPage(currenPage, pageSize);